package _工具包整理._判空;


import _工具包整理._JSON转换.Xiaoming;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.util.ArrayList;

public class NullTest {

    @Test
    public void test01() {
        // 集合 为空
        System.out.println("CollectionUtils.isEmpty(null) = " + CollectionUtils.isEmpty(null));
        System.out.println("CollectionUtils.isEmpty(new ArrayList<>()) = " + CollectionUtils.isEmpty(new ArrayList<>()));
    }

    @Test
    public void test02() {
        // 对象 为空
        Xiaoming xiaoming01 = null;
        System.out.println("xiaoming01 = " + xiaoming01);
        Xiaoming xiaoming02 = new Xiaoming();
        System.out.println("xiaoming02 = " + xiaoming02);
        System.out.println("xiaoming02.getName() = " + xiaoming02.getName());
        System.out.println(ObjectUtils.isEmpty(xiaoming01));
        System.out.println(ObjectUtils.isEmpty(xiaoming02));


    }

    @Test
    public void test03() {
        System.out.println(StringUtils.isEmpty(null));// true
        System.out.println(StringUtils.isEmpty(""));// true
        System.out.println(StringUtils.isEmpty("   "));// false
        System.out.println("-----------");
        System.out.println(StringUtils.isBlank(null));// true
        System.out.println(StringUtils.isBlank(""));// true
        System.out.println(StringUtils.isBlank("   "));// true
        System.out.println("+++++++++++");
        System.out.println(StringUtils.isAllEmpty(null, "", ""));
        System.out.println(StringUtils.isAllEmpty(null, "", " "));
    }

}
